/*
* © 2010 Autodata Solutions Company. All Rights Reserved
* This source code is the confidential and proprietary information of Autodata Solutions Company.
* The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
* without the prior written consent of Autodata Solutions Company.
*/
Ext.ns('net.autodata.compare.photos');
(function() {
	var DQ = Ext.DomQuery;
	
	/**
	 * @class PhotosView
	 * @extends net.autodata.AbstractView
	 * @namespace net.autodata.compare.photos
	 */
	var View = Ext.extend(net.autodata.AbstractView, {
		/**
		 * @property templates
		 * @type Object
		 */
		templates: undefined,
		
		cls: '',
		
		constructor: function () 
		{
			View.superclass.ctor.apply(this, arguments);
		},
		
		/**
		 * @method initTemplates
		 */
		initTemplates: function ()
		{
			var ts = this.templates || {};
			
			if (!ts.mainTpl) {
				ts.mainTpl = new Ext.XTemplate(
					'<div class="photos-view {viewCls}" style="{[this.viewWidth(values.width)]}{[this.viewHeight(values.height)]}">',
						'<div class="photo-selector"><div class="photo-selector-wrap"></div></div>',
						'<div class="vehicle-photos"><div class="vehicle-photos-wrap"></div></div>',							
					'</div>',
					{
						viewWidth: function (v)
						{
							return v ? String.format('width:{0}px;', v) : '';
						},
						
						viewHeight: function (v)
						{
							return v ? String.format('height:{0}px;', v) : '';
						},
						compiled: true,
						disableFormats: true
					}
				);
			}
			
			this.templates = ts;
		},
		
		/**
		 * @method getTemplateArgs
		 * @private
		 */
		getTemplateArgs: function ()
		{
			var p = this.component;
			return {
				viewCls: this.cls,
				width: p.width,
				height: p.height
			}
		},
				
		/**
		 * @method render
		 */
		render: function ()
		{
			var panel = this.component;
			this.templates.mainTpl.overwrite(panel.el.dom, this.getTemplateArgs());
			
			panel.photoSelector.render(DQ.selectNode('.photo-selector-wrap', panel.el.dom));
			panel.vehiclePhotos.render(DQ.selectNode('.vehicle-photos-wrap', panel.el.dom));
		}
	});
	
	net.autodata.compare.photos.PhotosView = View;
	
})();